package mylab.usm.oauth2.server.utils;

import cn.hutool.core.bean.BeanUtil;
import com.fujieid.jap.ids.model.ClientDetail;
import com.fujieid.jap.ids.model.UserInfo;
import lombok.experimental.UtilityClass;
import mylab.usm.api.model.account.App;
import mylab.usm.api.model.account.User;

/**
 * @Description:
 * @author: Sylar
 * @date: 2021年11月29日 4:31 下午
 */
@UtilityClass
public class PojoUtil {


    public ClientDetail clientFromEntity(App foo) {
        if (foo == null) return null;
        ClientDetail pojo = new ClientDetail();
        BeanUtil.copyProperties(foo, pojo, true);
        pojo.setAppName(foo.getName());
        pojo.setAvailable(!foo.getEnabled());
        return pojo;
    }

    public UserInfo userInfoFromEntity(User foo) {
        if (foo == null) return null;
        UserInfo pojo = new UserInfo();
        BeanUtil.copyProperties(foo, pojo, true);
        return pojo;
    }
}
